** Exiting Russia
** Wellhausen and Zhu
** .do file to run analyases in main paper + appendix
** using Stata 18


********************************************************************************
/* Notes to the reader: This is a master .do file that can be run to replicate the analyses in our paper. */
********************************************************************************
*ssc install regsave // useful package for capturing and reporting results
*ssc install estout

set more off
clear all

* set working directory

*************************************************************************************
*************************************************************************************
** Prep
*************************************************************************************
*************************************************************************************
use "master_exit_russia.dta", clear

************
**** Adjustments to create the estimation sample
************
drop if inactive==1 // Notes: These are firms that were inactive in the pre-invasion period and continued to be inactive at the end of the study period. Thus, we cannot confidently make inferences about their choices regarding exit. They are coded with exit as "missing," so they drop from the analyses by design. We drop them at this point in the .do file for clarity to the reader.
drop if exit_removed == 1 // This is a handful of obs (14) for which the BVD does not appear at the end of the period. We do not know what happened to these and therefore remove them from the sample.
drop if naics2022_2digit == 92 // This is a handful of obs (16) listed as having "public administration" (92) as their 2-digit NAICS industry. We inspected these and see that they are not profit-seeking, they seem to be associated with embassies and/or consulates. This industry is not part of FDI and thus including these in the sample would be an error; thus we drop them. 


************
**** Generating + labeling variables for presentation in output
************
encode home, gen(homeNUM) // for home fixed effect, based on the home of the BVD. 
* naics2022_2digit for industry FE

** Adjust and format variables
lab var soe "\hspace*{1em} State-owned"
lab var fs_stk_go_dum_median "\hspace*{1em} High fixed assets"
lab var russtrategic "\hspace*{1em} Russian strategic industry"
lab var yrsinrus  "\hspace*{1em} Years in Russia"
lab var multiple_homes "\hspace*{1em} Multiple foreign homes"
lab var foreign_by_guo "\hspace*{1em} Classification via parent"
lab var listed_nonRU_lfsh "\hspace*{1em} Listed outside of Russia"
lab var cyprus "\hspace*{1em} Cyprus"
lab var eu "\hspace*{1em} EU member"
lab var uk "\hspace*{1em} UK"
lab var taxhaven "\hspace*{1em} Tax haven"
lab var tradeflow_log "\hspace*{1em} Trade with Russia"
lab var econtreaty_count "\hspace*{1em} Economic treaties"
lab var ukraine "\hspace*{1em} Ukraine"
lab var multiple_fsh "\hspace*{1em} Multiple direct investors"
lab var iia "\hspace*{1em} IIA"
lab var pta "\hspace*{1em} PTA"
lab var dtt "\hspace*{1em} DTT"
lab var unfriendly "\hspace*{1em} Unfriendly home state"
lab var consumer_oriented_3digit_median "\hspace*{1em} Consumer-oriented industry"
lab var nslist "\hspace*{1em} On name-praise-shame list"

lab drop size
label define size 1 "\hspace*{1em} Small" 2 "\hspace*{1em} Medium" 3 "\hspace*{1em} Large" 4 "\hspace*{1em} Very Large"
label values size size

replace ruscontrol = 0 if foreign_by_guo == 1
lab var ruscontrol "\hspace*{1em} Russian managerial control"

gen ru_subsidiaries = max(ru_dependence_lfsh, ru_dependence_guo)/100
lab var ru_subsidiaries "\hspace*{1em} Russian subsidiary presence"

gen listed_nonRU = listed_nonRU_lfsh
replace listed_nonRU = 1 if listed_nonRU_guo==1
lab var listed_nonRU "\hspace*{1em} Listed outside Russia"

gen mixed_nat = (home_iso3!=guo_iso3)
replace mixed_nat=0 if missing(guo_iso3)
lab var mixed_nat "\hspace*{1em} Multiple home states"

gen mixed_ties = (unfriendly_bvd!=unfriendly_guo)
replace mixed_ties=0 if missing(guo_iso3)
lab var mixed_ties "\hspace*{1em} Mixed friendly $+$ unfriendly ties"

gen exit2 = exit
replace exit2 = 2 if exit_f2d ==1
replace exit2 = 3 if exit_f2f ==1

*****************
**** Setting estimation sample and saving covariates as macros for ease of readibility/analysis
*****************

** xtset
encode naics2022_2digit_v2, gen(naics2022_2digit_v2NUM) 
replace naics2022_2digit_v2NUM=. if missing(naics2022_2digit)
xtset naics2022_2digit_v2NUM

** output macros
macro define output "se nodepvar b(3) se(3) tex nogap label nodep nonotes star(* 0.10 ** 0.05 *** 0.01)"
macro define probitoutput "se nodepvar b(3) se(3) tex nomtitle nogap label nodep nonotes star(* 0.10 ** 0.05 *** 0.01) drop(1.size *naics2022_2digit*)"

** covariate macros
macro define controls_firm  ru_subsidiaries soe yrsinrus 1.size 2.size 3.size 4.size listed_nonRU mixed_nat multiple_fsh foreign_by_guo //  
macro define controls_firm2 ru_subsidiaries soe yrsinrus listed_nonRU mixed_nat multiple_fsh foreign_by_guo // 
macro define controls_home taxhaven eu cyprus tradeflow_log uk ukraine iia pta dtt  // 
macro define controls_home2 taxhaven tradeflow_log iia pta dtt //
macro define hypvariables unfriendly nslist consumer_oriented_3digit_median ruscontrol russtrategic fs_stk_go_dum_median //
macro define hypvariables2 nslist consumer_oriented_3digit_median ruscontrol russtrategic fs_stk_go_dum_median //




*************************************************************************************
*************************************************************************************
** Analysis
*************************************************************************************
*************************************************************************************

********************************
** MAIN RESULTS
********************************

*****************
** Main results table: Formatted for main text (Table 4)
*****************
eststo m1: xtreg exit unfriendly nslist consumer_oriented_3digit_median $controls_firm , fe cluster(naics2022_2digit_v2NUM)
estadd local fe = "Yes"
eststo m2: xtreg exit unfriendly nslist consumer_oriented_3digit_median $controls_home $controls_firm , fe cluster(naics2022_2digit_v2NUM)
estadd local fe = "Yes"
eststo m3: xtreg exit ruscontrol russtrategic fs_stk_go_dum_median $controls_firm , fe cluster(naics2022_2digit_v2NUM)
estadd local fe = "Yes"
eststo m4: xtreg exit ruscontrol russtrategic fs_stk_go_dum_median $controls_home $controls_firm , fe cluster(naics2022_2digit_v2NUM)
estadd local fe = "Yes"
eststo m5: xtreg exit $hypvariables $controls_home $controls_firm, fe cluster(naics2022_2digit_v2NUM)
estadd local fe = "Yes"

** export results to a .tex table
esttab m1 m2 m3 m4 m5 using "tab_main.tex", ///
$output stats(N r2_o fe, fmt(0 2 0) layout(@ @ @) ///
  labels("\textit{N}" "R$^{2}$" "Industry FEs")) ///
title("Determinants of Foreign-Invested Firm Exit \label{tab_main}") replace ///
 addnotes("Notes: Robust standard errors in parentheses, clustered at the two-digit NAICS level; \sym{*} \(p<0.10\), \sym{**} \(p<0.05\)," "\sym{***} \(p<0.01\). Suppressed for presentation: \textsuperscript{a}DTT, PTA, UK, Ukraine; \textsuperscript{b}Size categories, Multiple homes," "Multiple direct investors, Classification via parent. Full results in Appendix Table 12.17." ) ///
refcat(unfriendly "\textit{Pressure to sell}" ruscontrol "\textit{Bargaining over terms}" taxhaven "\textit{Home level controls}\textsuperscript{a}" ru_subsidiaries "\textit{Firm level controls}\textsuperscript{b}", nolabel) ///
drop( dtt pta uk ukraine mixed_nat multiple_fsh foreign_by_guo 1.size 2.size 3.size 4.size) nomtitle  ///
order(unfriendly nslist consumer_oriented_3digit_median ruscontrol russtrategic fs_stk_go_dum_median $controls_home $controls_firm)


*****************
** Main results with limited controls (Appendix Table 12.16)
*****************
eststo m1: xtreg exit unfriendly nslist consumer_oriented_3digit_median, fe cluster(naics2022_2digit_v2NUM)
estadd local fe = "Yes"
eststo m2: xtreg exit unfriendly nslist consumer_oriented_3digit_median mixed_nat multiple_fsh foreign_by_guo, fe cluster(naics2022_2digit_v2NUM)
estadd local fe = "Yes"
eststo m3: xtreg exit ruscontrol russtrategic fs_stk_go_dum_median, fe cluster(naics2022_2digit_v2NUM)
estadd local fe = "Yes"
eststo m4: xtreg exit ruscontrol russtrategic fs_stk_go_dum_median mixed_nat multiple_fsh foreign_by_guo, fe cluster(naics2022_2digit_v2NUM)
estadd local fe = "Yes"
eststo m5: xtreg exit unfriendly nslist consumer_oriented_3digit_median  ruscontrol russtrategic fs_stk_go_dum_median, fe cluster(naics2022_2digit_v2NUM)
estadd local fe = "Yes"
eststo m6: xtreg exit unfriendly nslist consumer_oriented_3digit_median  ruscontrol russtrategic fs_stk_go_dum_median mixed_nat multiple_fsh foreign_by_guo, fe cluster(naics2022_2digit_v2NUM)
estadd local fe = "Yes"

** export results to a .tex table
esttab m1 m2 m3 m4 m5 m6 using "tab_main_nocontrol.tex", ///
$output stats(N r2_o fe, fmt(0 2 0) layout(@ @ @) ///
  labels("\textit{N}" "R$^{2}$" "Industry FEs")) ///
title("Determinants of Foreign-Invested Firm Exit: Limited controls \label{tab_main_nocontrol}") replace ///
 addnotes("Notes: Robust standard errors in parentheses, clustered at the two-digit NAICS level; " "\sym{*} \(p<0.10\), \sym{**} \(p<0.05\), \sym{***} \(p<0.01\).") ///
refcat(unfriendly "\textit{Pressure to sell}" ruscontrol "\textit{Bargaining over terms}" mixed_nat "\textit{Data-related firm level controls}", nolabel) ///
order($hypvariables) nomtitle ///
 
 
*****************
** Main results table: Full, no covariates suppressed (Appendix Table 12.17)
*****************
eststo m1: xtreg exit unfriendly nslist consumer_oriented_3digit_median $controls_firm , fe cluster(naics2022_2digit_v2NUM)
estadd local fe = "Yes"
eststo m2: xtreg exit unfriendly nslist consumer_oriented_3digit_median $controls_home $controls_firm , fe cluster(naics2022_2digit_v2NUM)
estadd local fe = "Yes"
eststo m3: xtreg exit ruscontrol russtrategic fs_stk_go_dum_median $controls_firm , fe cluster(naics2022_2digit_v2NUM)
estadd local fe = "Yes"
eststo m4: xtreg exit ruscontrol russtrategic fs_stk_go_dum_median $controls_home $controls_firm , fe cluster(naics2022_2digit_v2NUM)
estadd local fe = "Yes"
eststo m5: xtreg exit $hypvariables $controls_home $controls_firm, fe cluster(naics2022_2digit_v2NUM)
estadd local fe = "Yes"

** save results for coefficient plots
regsave using "regcoef_main.dta" , tstat pval replace // save coefs for coefplot

** export results to a .tex table
esttab m1 m2 m3 m4 m5 using "tab_main_full.tex", ///
$output stats(N r2_o fe, fmt(0 2 0) layout(@ @ @) ///
  labels("\textit{N}" "R$^{2}$" "Industry FEs")) ///
title("Determinants of Foreign-Invested Firm Exit: Full results \label{tab_main_full}") replace ///
 addnotes("Notes: Robust standard errors in parentheses, clustered at the two-digit NAICS level; " "\sym{*} \(p<0.10\), \sym{**} \(p<0.05\), \sym{***} \(p<0.01\).") ///
 refcat(unfriendly "\textit{Pressure to sell}" ruscontrol "\textit{Bargaining over terms}" taxhaven "\textit{Home level controls}" ru_subsidiaries "\textit{Firm level controls}", nolabel) ///
order($hypvariables $controls_home ) nomtitle drop(1.size)



 

********************************
** MAIN RESULTS - ROBUSTNESS CHECKS
********************************

*****************
** Main results table: Probit (Appendix Table 12.18)
*****************
eststo m1: probit exit unfriendly nslist consumer_oriented_3digit_median $controls_firm i.naics2022_2digit_v2NUM, vce(cluster naics2022_2digit_v2NUM)
estadd local fe = "Yes"
eststo m2: probit exit unfriendly nslist consumer_oriented_3digit_median $controls_home $controls_firm i.naics2022_2digit_v2NUM, vce(cluster naics2022_2digit_v2NUM)
estadd local fe = "Yes"
eststo m3: probit exit ruscontrol russtrategic fs_stk_go_dum_median $controls_firm i.naics2022_2digit_v2NUM, vce(cluster naics2022_2digit_v2NUM)
estadd local fe = "Yes"
eststo m4: probit exit ruscontrol russtrategic fs_stk_go_dum_median $controls_home $controls_firm i.naics2022_2digit_v2NUM, vce(cluster naics2022_2digit_v2NUM)
estadd local fe = "Yes"
eststo m5: probit exit $hypvariables $controls_home $controls_firm i.naics2022_2digit_v2NUM, vce(cluster naics2022_2digit_v2NUM)
estadd local fe = "Yes"

** export results to a .tex table
esttab m1 m2 m3 m4 m5 using "tab_main_probit.tex", ///
$probitoutput stats(N N_clust r2_p fe, fmt(0 0 2 0) layout(@ @ @ @) ///
  labels("\textit{N}" "Number of Industries" "Pseudo R$^{2}$" "Industry FEs")) ///
title("Determinants of Foreign-Invested Firm Exit (Probit) \label{tab_main_probit}") replace ///
 addnotes("Notes: Robust standard errors in parentheses, clustered at the two-digit NAICS level; " "\sym{*} \(p<0.10\), \sym{**} \(p<0.05\), \sym{***} \(p<0.01\).") ///
 refcat(unfriendly "\textit{Pressure to sell}" ruscontrol "\textit{Bargaining over terms}" tradeflow_log "\textit{Home level controls}" yrsinrus "\textit{Firm level controls}", nolabel)  eqlabel(none) order($hypvariables $controls_home )


*****************
** Additional robustness checks: Compiled (Appendix Table 12.19)
*****************
**** prep additional variables
macro define add_controls_home agree_2017_21 gdppc_log libdem_vdem
lab var gdppc_log "\hspace*{1em} GDP PC (log)"
lab var libdem_vdem "\hspace*{1em} Liberal Democracy"
lab var agree_2017_21 "\hspace*{1em} UNGA Voting Similarity"

** drop observations linked to expropriation
eststo m1: xtreg exit $hypvariables $controls_home $controls_firm if robust_exprop==0, fe cluster(naics2022_2digit_v2NUM)
estadd local fe = "Yes"
estadd local home = "No"

** drop Cyprus and tax havens
eststo m2: xtreg exit $hypvariables eu uk ukraine tradeflow_log iia pta dtt $controls_firm if cyprus==0&taxhaven==0, fe cluster(naics2022_2digit_v2NUM)
estadd local fe = "Yes"
estadd local home = "No"

** drop obs without GUO recorded 
eststo m3: xtreg exit $hypvariables $controls_home $controls_firm if !missing(guo_iso3), fe cluster(naics2022_2digit_v2NUM)
estadd local fe = "Yes"
estadd local home = "No"

** Add additional home-level controls
eststo m4: xtreg exit $hypvariables $controls_home $add_controls_home $controls_firm , fe cluster(naics2022_2digit_v2NUM)
estadd local fe = "Yes"
estadd local home = "No"

** Home FEs
eststo m5: xtreg exit $hypvariables2 $controls_firm i.home_index, fe cluster(naics2022_2digit_v2NUM)
estadd local fe = "Yes"
estadd local home = "Yes"

** export results to a .tex table
esttab m1 m2 m3 m4 m5 using "tab_robustness.tex", ///
$output stats(N N_g r2_o fe home, fmt(0 0 2 0 0) layout(@ @ @ @ @) ///
  labels("\textit{N}" "Number of Industries" "R$^{2}$" "Industry FEs" "Home FEs")) ///
title("Determinants of Foreign-Invested Firm Exit: Additional robustness checks \label{tab_robustness}") replace ///
 addnotes("Notes: Robust standard errors in parentheses, clustered at the two-digit NAICS level; " "\sym{*} \(p<0.10\), \sym{**} \(p<0.05\), \sym{***} \(p<0.01\).") ///
 refcat(unfriendly "\textit{Pressure to sell}" ruscontrol "\textit{Bargaining over terms}" tradeflow_log "\textit{Home level controls}" yrsinrus "\textit{Firm level controls}", nolabel)  ///
drop(1.size *home_index*) order($hypvariables $controls_home iia pta dtt $add_controls_home) ///
 mgroups( "No Exprop-linked" "No CYP/Haven" "Obs w/ GUO50" "Addtl Home cntrls" "Home FE", pattern(1 1 1 1 1) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) nomtitle

 
*****************
** Additional robustness checks: Different operationalizations (Appendix 12.20)
*****************
**** prep additional variables
macro define hypvariables3 unfriendly nslist consumer_oriented_3digit_mean ruscontrol russtrategic fastock_byoutput
lab var consumer_oriented_3digit_mean "\textbf{\hspace*{1em} Consumer orientation: Mean cutoff}"
lab var fastock_byoutput "\textbf{\hspace*{1em} Fixed assets: Continuous}"

** Mean cutoff
eststo m1: xtreg exit unfriendly nslist consumer_oriented_3digit_mean $controls_firm, fe cluster(naics2022_2digit_v2NUM)
estadd local fe = "Yes"
eststo m2: xtreg exit unfriendly nslist consumer_oriented_3digit_mean $controls_home $controls_firm, fe cluster(naics2022_2digit_v2NUM)
estadd local fe = "Yes"

** Continuous fixed assets
eststo m3: xtreg exit ruscontrol russtrategic fastock_byoutput $controls_firm, fe cluster(naics2022_2digit_v2NUM)
estadd local fe = "Yes"
eststo m4: xtreg exit ruscontrol russtrategic fastock_byoutput $controls_home $controls_firm, fe cluster(naics2022_2digit_v2NUM)
estadd local fe = "Yes"

** Both
eststo m5: xtreg exit $hypvariables3 $controls_home $controls_firm, fe cluster(naics2022_2digit_v2NUM)
estadd local fe = "Yes"

esttab m1 m2 m3 m4 m5 using "tab_consumer_hfa.tex", ///
$output stats(N N_g r2_o fe, fmt(0 0 2 0) layout(@ @ @ @) ///
  labels("\textit{N}" "Number of Industries" "R$^{2}$" "Industry FEs")) ///
title("Determinants of Foreign-Invested Firm Exit: Alt. operationalizations \label{tab_consumer_hfa}") replace ///
 addnotes("Notes: Robust standard errors in parentheses, clustered at the two-digit NAICS level; \sym{*} \(p<0.10\), \sym{**} \(p<0.05\)," "\sym{***} \(p<0.01\). Suppressed for presentation: \textsuperscript{a}PTA, EU, UK, Ukraine; \textsuperscript{b}Size categories, Multiple homes," "Multiple direct investors, Classification via parent." ) ///
 refcat(unfriendly "\textit{Pressure to sell}\textsuperscript{a}" ruscontrol "\textit{Bargaining over terms}\textsuperscript{a}" tradeflow_log "\textit{Home level controls}" yrsinrus "\textit{Firm level controls}\textsuperscript{b}}", nolabel)  ///
order(unfriendly nslist consumer_oriented_3digit_mean ruscontrol russtrategic fastock_byoutput $controls_home ) nomtitle drop(pta eu uk ukraine mixed_nat multiple_fsh foreign_by_guo 1.size 2.size 3.size 4.size)


*****************
** Unpacking industry (Appendix Table 12.13)
*****************
lab var ff_consumergoods "Consumer-oriented (alt)" // =1 for 2 of 12 FF industries
lab var ff_hfa12only "High fixed assets (alt)" // =1 for 3 of 12 FF industries
drop ff_Num

eststo m1: reg exit $hypvariables3 $controls_home $controls_firm ff_consumergoods ff_hfa12only $ff1 , vce(cluster ff_Num)
estadd local controls = "Yes"
eststo m2: reg exit $hypvariables3 $controls_home $controls_firm ff_Durbl ff_NoDur ff_Enrgy ff_Utils ff_Telcm $ff1 , vce(cluster ff_Num2)
estadd local controls = "Yes"

** export results to a .tex table
esttab m1 m2 using "tab_industry.tex", ///
$output stats(controls controls N r2 , fmt(0 0 0 2) layout(@ @ @ @) ///
  labels("Hypothesis variables" "Home- \& Firm-level controls" "\textit{N}" "R$^{2}$")) ///
title("Determinants of Foreign-Invested Firm Exit: Alternative industry classifications \label{tab_industry}") replace ///
 addnotes("Notes: Robust standard errors in parentheses, clustered by industry;" "industry reference category = manufacturing;" "\sym{*} \(p<0.10\), \sym{**} \(p<0.05\), \sym{***} \(p<0.01\).") ///
order(unfriendly nslist ff_consumergoods ff_Durbl ff_NoDur ruscontrol russtrategic ff_hfa12only ff_Enrgy ff_Utils ff_Telcm $ff1  ) ///
 refcat(unfriendly "\textit{Pressure to sell}" ruscontrol "\textit{Bargaining over terms}" tradeflow_log "\textit{Home level controls}" yrsinrus "\textit{Firm level controls}", nolabel) ///
nomtitle drop($hypvariables3 $controls_home $controls_firm2 *size* )  




********************************
** HETEROGENEOUS EFFECTS
********************************

*****************
** Heterogeneity by unfriendly status (Appendix Table 12.14)
*****************
** Unfriendly
eststo t2a: xtreg exit $hypvariables2 $controls_home $controls_firm if unfriendly==1, fe cluster(naics2022_2digit_v2NUM)
estadd local fe = "Yes"
** save results for coefficient plots
regsave using "regcoef_unfriendly.dta" , tstat pval replace // save coefs for coefplot
** Friendly
eststo t2b: xtreg exit $hypvariables2 $controls_home2 $controls_firm if unfriendly==0, fe cluster(naics2022_2digit_v2NUM)
estadd local fe = "Yes"

** save results for coefficient plots
regsave using "regcoef_friendly.dta" , tstat pval replace // save coefs for coefplot

** export results to a .tex table
esttab t2a t2b using "tab_byunfriendly.tex", ///
$output stats(N N_g r2_o fe, fmt(0 0 2 0) layout(@ @ @ @) ///
  labels("\textit{N}" "Number of Industries" "R$^{2}$" "Industry FEs")) ///
title("Determinants of Foreign-Invested Firm Exit: By Home Status \label{tab_byunfriendly}") replace ///
 addnotes("Notes: Robust standard errors in parentheses, clustered at the two-digit NAICS level; " "\sym{*} \(p<0.10\), \sym{**} \(p<0.05\), \sym{***} \(p<0.01\).") ///
 refcat(nslist "\textit{Pressure to sell}" ruscontrol "\textit{Bargaining over terms}" taxhaven "\textit{Home level controls}" ru_subsidiaries "\textit{Firm level controls}", nolabel) ///
mtitles("Unfriendly" "Friendly") drop(1.size)


*****************
** Heterogeneity by size (Appendix Table 12.15)
*****************
** Small, and save results
eststo m1: xtreg exit $hypvariables $controls_home $controls_firm2  if size==1, fe cluster(naics2022_2digit_v2NUM)
estadd local fe = "Yes"
regsave using "regcoef_small.dta" , tstat pval replace
** Medium, and save results
eststo m2: xtreg exit $hypvariables $controls_home $controls_firm2  if size==2, fe cluster(naics2022_2digit_v2NUM)
estadd local fe = "Yes"
regsave using "regcoef_medium.dta" , tstat pval replace
** Large, and save results
eststo m3: xtreg exit $hypvariables $controls_home $controls_firm2  if size==3, fe cluster(naics2022_2digit_v2NUM)
estadd local fe = "Yes"
regsave using "regcoef_large.dta" , tstat pval replace
** Very large, and save results
eststo m4: xtreg exit $hypvariables $controls_home $controls_firm2  if size==4, fe cluster(naics2022_2digit_v2NUM)
estadd local fe = "Yes"

** save results for coefficient plots
regsave using "regcoef_verylarge.dta" , tstat pval replace

** export results to a .tex table
esttab m1 m2 m3 m4 using "tab_size.tex", ///
$output stats(N N_g r2_o fe, fmt(0 0 2 0) layout(@ @ @ @) ///
  labels("\textit{N}" "Number of Industries" "R$^{2}$" "Industry FEs")) ///
title("Determinants of Foreign-Invested Firm Exit: By Size \label{tab_size}") replace ///
 addnotes("Notes: Robust standard errors in parentheses, clustered at the two-digit NAICS level; " "\sym{*} \(p<0.10\), \sym{**} \(p<0.05\), \sym{***} \(p<0.01\).") ///
 refcat(unfriendly "\textit{Pressure to sell}" ruscontrol "\textit{Bargaining over terms}" tradeflow_log "\textit{Home level controls}" yrsinrus "\textit{Firm level controls}", nolabel) ///
mtitles("Small" "Medium" "Large" "Vary Large")


*****************
** Heterogeneity by praise/shame (Appendix Table 12.21)
*****************
**** prep additional variables
lab var nslist_praise "\hspace*{1em} Named + Praised"
gen nslist_shame=0
*tab nslist_praise if nslist==1
replace nslist_shame=1 if nslist==1 & nslist_praise==0
lab var nslist_shame "\hspace*{1em} Named + Shamed"

macro define hypvariables4 unfriendly nslist_praise nslist_shame consumer_oriented_3digit_median ruscontrol russtrategic fs_stk_go_dum_median //

** Separate out nslist praise and shame
eststo m1: xtreg exit $hypvariables4 $controls_home $controls_firm, fe cluster(naics2022_2digit_v2NUM)
estadd local fe = "Yes"

** Drop praise
eststo m2 : xtreg exit $hypvariables4 $controls_home $controls_firm if nslist_praise==0, fe cluster(naics2022_2digit_v2NUM)
estadd local fe = "Yes"

** export results to a .tex table
esttab m1 m2 using "tab_praise.tex", ///
$output stats(N r2_o fe, fmt(0 2 0) layout(@ @ @) ///
  labels("\textit{N}" "R$^{2}$" "Industry FEs")) ///
title("Determinants of Foreign-Invested Firm Exit: Praise or Shame? \label{tab_praise}") replace ///
 addnotes("Notes: Robust standard errors in parentheses, clustered at the two-digit NAICS level; \sym{*} \(p<0.10\), \sym{**} \(p<0.05\)," "\sym{***} \(p<0.01\). Suppressed for presentation: \textsuperscript{a}PTA, EU, UK, Ukraine; \textsuperscript{b}Size categories, Multiple homes," "Multiple direct investors, Classification via parent." ) ///
refcat(unfriendly "\textit{Pressure to sell}" ruscontrol "\textit{Bargaining over terms}" tradeflow_log "\textit{Home level controls}\textsuperscript{a}" yrsinrus "\textit{Firm level controls}\textsuperscript{b}", nolabel) ///
 drop(pta eu uk ukraine mixed_nat multiple_fsh foreign_by_guo 1.size 2.size 3.size 4.size) ///
mtitles("Separate" "Drop Praised") ///
order(unfriendly nslist_praise nslist_shame consumer_oriented_3digit_median ruscontrol russtrategic fs_stk_go_dum_median $controls_home $controls_firm)


*****************
** Heterogeneity by type of exit - Multinominal logit (Table 12.22)
*****************
eststo mlogit1: mlogit exit2 $hypvariables $controls_home $controls_firm i.naics2022_2digit_v2NUM, vce(cluster naics2022_2digit_v2NUM)
estadd local fe = "Yes"

** save results for coefficient plots
regsave using "regcoef_mlogit.dta" , tstat pval replace 

** export results to a .tex table
esttab mlogit1 using "tab_mlogit.tex", ///
$output stats(N N_clust r2_p fe, fmt(0 0 2 0) layout(@ @) ///
  labels("\textit{N}" "Number of Industries" "Pseudo R$^{2}$" "Industry FEs")) ///
title("Determinants of Foreign-Invested Firm Exit (Multinominal Logit) \label{tab_mlogit}") replace ///
 addnotes("Notes: Robust standard errors in parentheses, clustered at the two-digit NAICS level; " "\sym{*} \(p<0.10\), \sym{**} \(p<0.05\), \sym{***} \(p<0.01\).") nomtitle drop(1.size *naics2022_2digit* ) keep(1: 2: 3:) ///
 refcat(unfriendly "\textit{Pressure to sell}" ruscontrol "\textit{Bargaining over terms}" tradeflow_log "\textit{Home level controls}" yrsinrus "\textit{Firm level controls}", nolabel)  unstack order($hypvariables) ///
eqlabels("Active to Inactive" "Foreign to Domestic" "Foreign to Foreign") nonum


*****************
** Placebo test 2020–2021
*****************

*****************
** Prep
*****************
clear all
use "placebo_exit_russia_2020-21", clear

************
**** Adjustments to create the estimation sample
************
drop if inactive==1 
drop if naics2022_2digit == 92 


************
**** Generating + labeling variables for presentation in output
************
encode home, gen(homeNUM) // for home fixed effect, based on the home of the BVD. 
* naics2022_2digit for industry FE

lab var soe "\hspace*{1em} State-owned"
lab var fs_stk_go_dum_median "\hspace*{1em} High fixed assets"
lab var russtrategic "\hspace*{1em} Russian strategic industry"
lab var yrsinrus  "\hspace*{1em} Years in Russia"
lab var multiple_homes "\hspace*{1em} Multiple foreign homes"
lab var foreign_by_guo "\hspace*{1em} Classification via parent"
lab var listed_nonRU_lfsh "\hspace*{1em} Listed outside of Russia"
lab var cyprus "\hspace*{1em} Cyprus"
lab var eu "\hspace*{1em} EU member"
lab var uk "\hspace*{1em} UK"
lab var taxhaven "\hspace*{1em} Tax haven"
lab var tradeflow_log "\hspace*{1em} Trade with Russia"
lab var econtreaty_count "\hspace*{1em} Economic treaties"
lab var ukraine "\hspace*{1em} Ukraine"
lab var multiple_fsh "\hspace*{1em} Multiple direct investors"
lab var iia "\hspace*{1em} IIA"
lab var pta "\hspace*{1em} PTA"
lab var dtt "\hspace*{1em} DTT"
lab var unfriendly "\hspace*{1em} Unfriendly home state"
lab var consumer_oriented_3digit_median "\hspace*{1em} Consumer-oriented industry"

lab drop size
label define size 1 "\hspace*{1em} Small" 2 "\hspace*{1em} Medium" 3 "\hspace*{1em} Large" 4 "\hspace*{1em} Very Large"
label values size size

replace ruscontrol = 0 if foreign_by_guo == 1
lab var ruscontrol "\hspace*{1em} Russian managerial control"

gen ru_subsidiaries = max(ru_dependence_lfsh, ru_dependence_guo)/100
lab var ru_subsidiaries "\hspace*{1em} Russian subsidiary presence"

replace nslist=0 if missing(nslist)
lab var nslist "\hspace*{1em} On name-praise-shame list"

gen listed_nonRU = listed_nonRU_lfsh
replace listed_nonRU = 1 if listed_nonRU_guo==1
lab var listed_nonRU "\hspace*{1em} Listed outside of Russia"

gen mixed_nat = (home_iso3!=guo_iso3)
replace mixed_nat=0 if missing(guo_iso3)
lab var mixed_nat "\hspace*{1em} Multiple home states"

gen mixed_ties = (unfriendly_bvd!=unfriendly_guo)
replace mixed_ties=0 if missing(guo_iso3)
lab var mixed_ties "\hspace*{1em} Mixed friendly $+$ unfriendly ties"

gen exit2 = exit
replace exit2 = 2 if exit_f2d ==1
replace exit2 = 3 if exit_f2f ==1


*****************
**** Setting estimation sample and saving covariates as macros for ease of readibility/analysis
*****************
encode naics2022_2digit_shorttext, gen(naics2022_2digit_v2NUM) 
replace naics2022_2digit_v2NUM=. if missing(naics2022_2digit)
xtset naics2022_2digit_v2NUM

** output macros
macro define output "se nodepvar b(3) se(3) tex nogap label nodep nonotes star(* 0.10 ** 0.05 *** 0.01)"
macro define probitoutput "se nodepvar b(3) se(3) tex nomtitle nogap label nodep nonotes star(* 0.10 ** 0.05 *** 0.01) drop(1.size *naics2022_2digit*)"

** covariate macros
macro define controls_firm  ru_subsidiaries soe yrsinrus 1.size 2.size 3.size 4.size listed_nonRU mixed_nat multiple_fsh foreign_by_guo //  
macro define controls_home taxhaven eu cyprus tradeflow_log uk ukraine iia pta dtt  // 
macro define hypvariables unfriendly nslist consumer_oriented_3digit_median ruscontrol russtrategic fs_stk_go_dum_median //

*****************
** Appendix Table 11.10
*****************

eststo t1a: xtreg exit unfriendly nslist consumer_oriented_3digit_median $controls_firm , fe cluster(naics2022_2digit_v2NUM)
estadd local fe = "Yes"
eststo t1b: xtreg exit unfriendly nslist consumer_oriented_3digit_median $controls_home $controls_firm , fe cluster(naics2022_2digit_v2NUM)
estadd local fe = "Yes"
eststo t1c: xtreg exit ruscontrol russtrategic fs_stk_go_dum_median $controls_firm , fe cluster(naics2022_2digit_v2NUM)
estadd local fe = "Yes"
eststo t1f: xtreg exit ruscontrol russtrategic fs_stk_go_dum_median $controls_home $controls_firm , fe cluster(naics2022_2digit_v2NUM)
estadd local fe = "Yes"
eststo t1d: xtreg exit $hypvariables $controls_home $controls_firm, fe cluster(naics2022_2digit_v2NUM)
estadd local fe = "Yes"
eststo t1e: xtreg exit consumer_oriented_3digit_median ruscontrol russtrategic fs_stk_go_dum_median $controls_home $controls_firm, fe cluster(naics2022_2digit_v2NUM)
estadd local fe = "Yes"

** export results to a .tex table
esttab t1a t1b t1c t1d t1e using "tab_main_placebo.tex", ///
$output stats(N r2_o fe, fmt(0 2 0) layout(@ @ @) ///
  labels("\textit{N}" "R$^{2}$" "Industry FEs")) ///
title("Determinants of Foreign-Invested Firm Exit (2020--2021) \label{tab_main_placebo}") replace ///
 addnotes("Notes: Robust standard errors in parentheses, clustered at the two-digit NAICS level; " "\sym{*} \(p<0.10\), \sym{**} \(p<0.05\), \sym{***} \(p<0.01\).") ///
 refcat(unfriendly "\textit{Pressure to sell}" ruscontrol "\textit{Bargaining over terms}" tradeflow_log "\textit{Home level controls}" yrsinrus "\textit{Firm level controls}", nolabel) ///
order($hypvariables $controls_home ) nomtitle drop(1.size)


*****************
** Placebo test 2013–2014
*****************

*****************
** Prep
*****************
clear all

use "placebo_exit_russia_2013-14.dta", clear

************
**** Adjustments to create the estimation sample
************
drop if inactive==1 
drop if naics2022_2digit == 92 

************
**** Generating + labeling variables for presentation in output
************
encode home, gen(homeNUM) // for home fixed effect, based on the home of the BVD. 
* naics2022_2digit for industry FE

lab var soe "\hspace*{1em} State-owned"
lab var fs_stk_go_dum_median "\hspace*{1em} High fixed assets"
lab var russtrategic "\hspace*{1em} Russian strategic industry"
lab var yrsinrus  "\hspace*{1em} Years in Russia"
lab var multiple_homes "\hspace*{1em} Multiple foreign homes"
lab var foreign_by_guo "\hspace*{1em} Classification via parent"
lab var listed_nonRU_lfsh "\hspace*{1em} Listed outside of Russia"
lab var cyprus "\hspace*{1em} Cyprus"
lab var eu "\hspace*{1em} EU member"
lab var uk "\hspace*{1em} UK"
lab var taxhaven "\hspace*{1em} Tax haven"
lab var tradeflow_log "\hspace*{1em} Trade with Russia"
lab var econtreaty_count "\hspace*{1em} Economic treaties"
lab var ukraine "\hspace*{1em} Ukraine"
lab var multiple_fsh "\hspace*{1em} Multiple direct investors"
lab var iia "\hspace*{1em} IIA"
lab var pta "\hspace*{1em} PTA"
lab var dtt "\hspace*{1em} DTT"
lab var unfriendly "\hspace*{1em} Unfriendly home state"
lab var consumer_oriented_3digit_median "\hspace*{1em} Consumer-oriented industry"

lab drop size
label define size 1 "\hspace*{1em} Small" 2 "\hspace*{1em} Medium" 3 "\hspace*{1em} Large" 4 "\hspace*{1em} Very Large"
label values size size

replace ruscontrol = 0 if foreign_by_guo == 1
lab var ruscontrol "\hspace*{1em} Russian managerial control"

gen ru_subsidiaries = max(ru_dependence_lfsh, ru_dependence_guo)/100
lab var ru_subsidiaries "\hspace*{1em} Russian subsidiary presence"

replace nslist=0 if missing(nslist)
lab var nslist "\hspace*{1em} On name-praise-shame list"

gen listed_nonRU = listed_nonRU_lfsh
replace listed_nonRU = 1 if listed_nonRU_guo==1
lab var listed_nonRU "\hspace*{1em} Listed outside of Russia"

gen mixed_nat = (home_iso3!=guo_iso3)
replace mixed_nat=0 if missing(guo_iso3)
lab var mixed_nat "\hspace*{1em} Multiple home states"

gen mixed_ties = (unfriendly_bvd!=unfriendly_guo)
replace mixed_ties=0 if missing(guo_iso3)
lab var mixed_ties "\hspace*{1em} Mixed friendly $+$ unfriendly ties"

gen exit2 = exit
replace exit2 = 2 if exit_f2d ==1
replace exit2 = 3 if exit_f2f ==1


*****************
**** Setting estimation sample and saving covariates as macros for ease of readibility/analysis
*****************
encode naics2022_2digit_shorttext, gen(naics2022_2digit_v2NUM) 
replace naics2022_2digit_v2NUM=. if missing(naics2022_2digit)
xtset naics2022_2digit_v2NUM

** output macros
macro define output "se nodepvar b(3) se(3) tex nogap label nodep nonotes star(* 0.10 ** 0.05 *** 0.01)"
macro define probitoutput "se nodepvar b(3) se(3) tex nomtitle nogap label nodep nonotes star(* 0.10 ** 0.05 *** 0.01) drop(1.size *naics2022_2digit*)"

** covariate macros
macro define controls_firm yrsinrus ru_subsidiaries soe listed_nonRU 1.size 2.size 3.size 4.size mixed_nat multiple_fsh foreign_by_guo //
macro define controls_home tradeflow_log taxhaven cyprus iia pta dtt eu uk ukraine // 
macro define hypvariables unfriendly nslist consumer_oriented_3digit_median ruscontrol russtrategic fs_stk_go_dum_median //


*****************
** Appendix Table 11.11
*****************
eststo t1a: xtreg exit unfriendly nslist consumer_oriented_3digit_median $controls_firm , fe cluster(naics2022_2digit_v2NUM)
estadd local fe = "Yes"
eststo t1b: xtreg exit unfriendly nslist consumer_oriented_3digit_median $controls_home $controls_firm , fe cluster(naics2022_2digit_v2NUM)
estadd local fe = "Yes"
eststo t1c: xtreg exit ruscontrol russtrategic fs_stk_go_dum_median $controls_firm , fe cluster(naics2022_2digit_v2NUM)
estadd local fe = "Yes"
eststo t1f: xtreg exit ruscontrol russtrategic fs_stk_go_dum_median $controls_home $controls_firm , fe cluster(naics2022_2digit_v2NUM)
estadd local fe = "Yes"
eststo t1d: xtreg exit $hypvariables $controls_home $controls_firm, fe cluster(naics2022_2digit_v2NUM)
estadd local fe = "Yes"
eststo t1e: xtreg exit consumer_oriented_3digit_median ruscontrol russtrategic fs_stk_go_dum_median $controls_home $controls_firm, fe cluster(naics2022_2digit_v2NUM)
estadd local fe = "Yes"


** export results to a .tex table
esttab t1a t1b t1c t1d t1e using "tab_main_placebo2014.tex", ///
$output stats(N r2_o fe, fmt(0 2 0) layout(@ @ @) ///
  labels("\textit{N}" "R$^{2}$" "Industry FEs")) ///
title("Determinants of Foreign-Invested Firm Exit (2013--2014) \label{tab_placebo2014}") replace ///
 addnotes("Notes: Robust standard errors in parentheses, clustered at the two-digit NAICS level; " "\sym{*} \(p<0.10\), \sym{**} \(p<0.05\), \sym{***} \(p<0.01\).") ///
 refcat(unfriendly "\textit{Pressure to sell}" ruscontrol "\textit{Bargaining over terms}" tradeflow_log "\textit{Home level controls}" yrsinrus "\textit{Firm level controls}", nolabel) ///
order($hypvariables $controls_home $controls_firm) nomtitle drop(1.size)



